<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/page_init.jsp"%>
 <%
 		String loginId = request.getParameter("loginId");
 %>

<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="<%=contextPath%>/js/common/plug-in/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=contextPath%>/js/common/plug-in/easyui/themes/icon.css">
<script type="text/javascript" src="<%=contextPath%>/js/common/plug-in/easyui/jquery.easyui.min.js"></script>
	<title>权限菜单选择</title>
</head>
<body>
 <div class="main-right l">
    <div class="main-right-scroll">
	<div class="title-bt"><span class="pl10">菜单权限列表</span><span class="pr10 tr">
        <button class="btn-28" id="bt_save">保存</button>
        </span>
     </div>
 	<ul id="tt" class="easyui-tree" ></ul>
</div>
</div>
</body>	
	<script type="text/javascript">
	$(function(){
		$('#tt').tree({
		    url:"loadMenuTree?loginId="+"<%=loginId%>",
		    method:'get',
		    animate:true,
		    checkbox:true
		});
		
		$("#bt_save").click(function() {
			
			Ajax({
				url:contextPath+"/console/user/updatePermission",
				isMask : true,
				data: {
					loginId : '<%=loginId%>',
					menuIds :getChecked()	
				},
				success: function (data) {
					if (data.success) {
						apexLayer.Msg("更改权限成功",1000,function(){
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
						});
					} else {
						apexLayer.Error(data.note);
					}
				}
			});

		});
		});
	function getChecked(){
	  var solids =  $('#tt').tree('getChecked', ['checked','indeterminate']);
	  var nodes = [];
	  $.each(solids,function(){
	    nodes.push(this.id);
	  });
		return nodes.join(",");
	}



	</script>
</body>
</html>